package com.uuj.project.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.blankj.utilcode.util.PermissionUtils;

/**
 * ProjectName:    stock
 * Package:        cn.com.yundanche.stock.utils
 * ClassName:      DialogHelper
 * Description:    弹窗工具类
 * Author:         张继
 * CreateDate:     2019/5/21 17:37
 * UpdateUser:     更新者
 * UpdateDate:     2019/5/21 17:37
 * UpdateRemark:   更新说明
 * Version:        1.0
 */
public final class DialogHelper {

    //            .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
    //    @Override
    //    public void onClick(DialogInterface dialog, int which) {
    //        shouldRequest.again(false);
    //    }
    //})
    public static void showRationaleDialog(Context context, Permission.OnRationaleListener.ShouldRequest shouldRequest) {
        new AlertDialog.Builder(context)
                .setTitle(android.R.string.dialog_alert_title)
                .setMessage("您拒绝了我们申请授权，请同意授权，否则该功能不能正常使用！")
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        shouldRequest.again(true);
                    }
                })
                .setCancelable(false)
                .create()
                .show();
    }


    public static void showOpenAppSettingDialog(Context context) {

        new AlertDialog.Builder(context)
                .setTitle(android.R.string.dialog_alert_title)
                .setMessage("我们需要一些您拒绝的权限或系统无法应用的失败，请手动设置到页面授权，否则该函数不能正常使用！")
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        PermissionUtils.launchAppDetailsSettings();
                    }
                })
                .setCancelable(false)
                .create().show();
    }


}
